      parameter (iylast=3000,i4=(iylast-1701+1)*12)
      integer info(9),idata(i4)
      character title*80,name*36,line*200

      open(1,file='fort.1',form='formatted')
      open(2,file='fort.2',form='unformatted')
      open(3,file='fort.3',form='unformatted')
      read(2) info,title
      write(3) info,title
      ibad=info(7)
      if(info(1).eq.ibad) stop 'no stations'
      m1o=info(1)
      m2o=info(9)
   10 read(2,end=300) (idata(i),i=m1o,m2o),Lat,Lon,ID,iht,name,m1,m2
   20 read(1,'(a)',end=400) line
      indcc=index(line,'cc')
      if(indcc.lt.80) stop 'cc missing'
      read(line(indcc-78:indcc-70),'(i9)') IDo
      if(ID.ne.IDo) go to 20
      name(28:30)=line(indcc+8:indcc+10)   ! add brightness index 0-254
      name(31:31)=line(indcc-3:indcc-3)    ! add US-brightness index 123
      name(32:32)=line(indcc-4:indcc-4)    ! add population flag     RSU
      name(33:33)=line(indcc-2:indcc-2)    ! add brightness index    ABC
      name(34:36)=line(indcc+3:indcc+5)    ! add country code
      write(3) (idata(i),i=m1o,m2o),Lat,Lon,ID,iht,name,m1,m2
      m1o=m1
      m2o=m2
      go to 10

  300 stop 0
  400 stop 'station-list too short'
      end
